Refactor source layout boundaries#25
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This keeps the public
captunlibrary surface insrc/index.ts, moves runtime-specific entrypoints and the self-hosted Tunnel Gateway undersrc/server, and leaves hosted product policy undersrc/hosted.The root library now owns the shared gateway connect constants and fetcher capability helpers directly. The broader hosted reserved-name list is hosted-only, while the self-hosted gateway only reserves the
captunandgatewaylabels that can collide with custom gateway hostnames.CLI tunnel retries now reuse one generated client token for any gateway, and
createCaptunTunnel()returns only the gateway-confirmed tunnel payload rather than falling back to the client token.Validation
pnpm run typecheckpnpm run buildpnpm run lintpnpm run format:checkpnpm testNote
Medium Risk
Medium risk from a wide file move plus changed tunnel token return semantics and reserved-name behavior on hosted vs self-hosted gateways; mitigated by updated tests and lint boundaries.
Overview
This PR restructures the repo so the public
captunAPI stays insrc/index.ts(Cap'n Web tunnel client, connect query constants, fetcher helpers,randomConnectToken), while runtime adapters and the self-hosted Cloudflare gateway move undersrc/server/(worker.ts,tunnel-addressing.ts,node/bun/deno). Hosted-only policy (broad reserved tunnel names,captun.shsite routing) lives undersrc/hosted/, with the self-hosted worker only blockingcaptunandgatewayon custom-domain deploys.Package and deploy paths now point at
src/server/worker.ts/dist/server/worker.js. Oxlint enforces that rootsrc/**may import onlycapnweb, with exceptions for CLI, server, hosted, tests, and examples.Connect/token behavior changes:
createCaptunTunnelalways attaches a generated token on connect when none is passed, but returns only what the gateway sends inready(no merging in a client token). The CLI generates one token per session and reuses it across retries for any gateway, not onlycaptun.sh.Docs, Miniflare fixtures, and tests were updated for the new layout and the split reserved-name rules.
Reviewed by Cursor Bugbot for commit 6963beb. Bugbot is set up for automated code reviews on this repo. Configure here.